package org.dromara.quickswing.events;

import com.google.common.eventbus.EventBus;
import org.dromara.quickswing.QSApplication;

public class QSEventBus {

    private final EventBus eventBus;

    public QSEventBus() {
        eventBus = new EventBus("QSEventBus initialize...");
    }

    public <T extends QSApplication> void subscribe(QSEventListener<T> listener) {
        eventBus.register(listener);
    }

    public <T extends QSApplication> void unsubscribe(QSEventListener<T> listener) {
        eventBus.unregister(listener);
    }

    public void publish(QSEvent event) {
        eventBus.post(event);
    }
}